package com.lfg.leetcode.leetcode0;

import java.util.ArrayList;
import java.util.List;

public class No89grayCode {

    public static void main(String[] args) {
        List<Integer> ret = grayCode(3);
        for (Integer i : ret) {
            System.out.println("[" + Integer.toBinaryString(i)+ "]");
        }
    }

    public static List<Integer> grayCode(int n) {
        int size = 1 << n;
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            int i1 = i >> 1;
            list.add(i ^ i1);
        }
        return list;
    }

}

